#include "../h/CEngine.h"

#ifdef AXELYNX_WIN32
#include "../h/CWin32Window.h"
#endif

#ifdef AXELYNX_MACOS
#include "../h/CMacOSWindow.h"
#endif

#ifdef AXELYNX_LINUX
#include "../h/CLinuxWindow.h"
#endif

using namespace axelynx;

FUNC_EXPORT Engine* Engine::Create(const EngineDesc &ed)
{
    if(ed.version != AXELYNX_VERSION)
        throw EngineInitError("Incomatable header and lib version!");

    return new CEngine();
}

CEngine::CEngine()
:app_(0)
{
    //ctor
}

CEngine::~CEngine()
{
    //dtor
}

void CEngine::Application(AxelynxApp *application)
{
    app_ = application;
}

void CEngine::Run()
{
    app_->SetEngine(this);

    app_->Initialisation();

    app_->DeInitialisation();
}

Window* CEngine::AddWindow(const WindowDesc &wd)
{
    Window *nw = 0; //new window


    #ifdef AXELYNX_WIN32


        nw = new CWin32Window(wd);
        nw->SetTitle(wd.caption_);


    #endif

    #ifdef AXELYNX_MACOS
        return new CMacOSWindow();
    #endif

    #ifdef AXELYNX_LINUX
        return new CLinuxWindow();
    #endif

    return nw;
}
